var str = 'jimmy';
var num = 24;
var bool = false;
var u = undefined;
var n = null;
var obj = { x: 1 };
// let v:void = null;
//对象数组和混合数组呢？
var arr = ['1', '2'];
var arr1 = ['1', '2'];
var arr2 = [1, 'a'];
var arr3 = [1, 'a'];
console.log('arr2:');
console.log(arr2);
var arr4 = [{ name: 'jimmy', age: 12 }];
//声明函数
function sum(x, y) {
    return x + y;
}
//函数表达式
var mySum = function (x, y) {
    return x + y;
};
// 可选参数，返回值可以不定义类型？——可以
// 默认值的话不需要带 ?
function buildName(firstName, lastName) {
    if (lastName === void 0) { lastName = 'cat'; }
    if (lastName) {
        return firstName + ' ' + lastName;
    }
    else {
        return firstName;
    }
}
sum(11, 11);
console.log(buildName('liu'));
// buildName();
//剩余参数
function push(array) {
    var items = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        items[_i - 1] = arguments[_i];
    }
    items.forEach(function (item) {
        array.push(item);
    });
}
var a = [];
push(a, 1, 2, 3, 4, 5);
console.log(a);
function add(x, y) {
    if (typeof x == 'string' || typeof y == 'string') {
        return x.toString() + y.toString();
    }
    return x + y;
}
console.log('add:');
var res = add(1, 2);
console.log(res);
console.log('add1:');
var res1 = add('1', '2');
console.log(res1);
console.log(res1.split(''));
var t;
t = ['hello', 10];
// t = ['hello', 10];
console.log(t);
var na = t[0], age = t[1];
var point = [10, 10];
// point[0] = 1;
var vv;
function func() {
    console.log('this is typescript');
}
func();
function err(msg) {
    throw new Error(msg);
}
function control(foo) {
    if (typeof foo == 'string') {
    }
    else if (typeof foo == 'number') {
    }
    else {
        var check = foo;
    }
}
// control(true);
var aaa = 123;
var nev;
aaa = nev;
aaa = 123;
aaa = null;
aaa = undefined;
var bbb;
bbb = aaa;
// aaa = bbb;
//unknown 只能赋值给 unknown 和 any，任意值可以赋值给 unknown
var kk;
// aaa = kk;
var dog = { hello: 'world' };
// dog.hello;
function getDogName() {
    var x;
    return x;
}
var dogName = getDogName();
// if(typeof dogName === 'string'){
//     let upName = dogName.toLowerCase();
// }
// let upName = (dogName as string).toLowerCase();
// 可以将 string、number、boolean、{} 赋值给 Object
var obj1;
obj1 = 1;
obj1 = 'a';
obj1 = true;
obj1 = {};
//只能将 {}  赋值给 object 类型
var obj2;
obj2 = {};
// console.log(extendObj);
var par1 = '123';
var par2 = '123';
var Num = 1234;
var num1 = 123;
// num1=Num;
// Num=num1;
var myFavoriteNumber;
myFavoriteNumber = 'serven';
myFavoriteNumber = 7;
function add1(x, y) {
    return x + y;
}
var A = /** @class */ (function () {
    function A(name, age) {
        this.str1 = 1;
        this.str = name;
    }
    A.prototype.getStr = function () {
        this.str = 'win7';
        console.log("str1: " + this.str);
    };
    return A;
}());
var aa = new A('katy', 31);
console.log(aa.str);
// console.log(A.str1);
aa.getStr();
//实现接口还得自己重写，这样真的好？
var Agr = /** @class */ (function () {
    function Agr(interest, rebate) {
        this.interest = interest;
        this.rebate = rebate;
    }
    return Agr;
}());
var agr = new Agr(10, 1);
console.log("\u5229\u6DA6\u4E3A\uFF1A" + agr.interest + ", \u62BD\u6210\u4E3A\uFF1A" + agr.rebate);
var sites = {
    site1: 'Runoob',
    site2: 'Google',
    sayHello: function () { } //这里不写，下面定义函数就会报错
};
sites.sayHello = function () {
};
/// <reference path="circle.ts"/>
var Drawing;
(function (Drawing) {
    var Circle = /** @class */ (function () {
        function Circle() {
        }
        // 公共方法居然
        Circle.prototype.draw = function () {
            console.log('Circle is drown');
        };
        return Circle;
    }());
    Drawing.Circle = Circle;
})(Drawing || (Drawing = {}));
